package com.workversion2.demo.controller;


import com.workversion2.demo.entity.student;
import com.workversion2.demo.repository.StudentRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.Optional;

@Controller
public class personController {
    @Autowired
    StudentRepository studentRepository;

   //    private Optional<student> stu;
    @ModelAttribute(value = "zhangshang")
    public Optional<student> getStudent(){
         return studentRepository.findById(1);
    }


    @RequestMapping(value = "/person")
    public String helloWorld() {
        return "person";
    }
}
